package edu.drexel.cs544.group11.common;

/**
 * This class represent a product in the inventory
 * 
 * CS 544
 * 
 * @author Group 11:
 * @author Jason Setzer
 * @author Tam Thongsima
 * @author Kenny Oyefara
 * @author Chase Miller
 * 
 * @date Spring 2013
 * 
 */
public class Product {
    private int Quantity;
    private String itemName;
    private double Price;
    private String Category;
    private String Barcode;
    
    /**
     * class constructor creates an instance of class with item name
     * 
     * @param itemName
     */
    public Product(String Barcode) {
	this.Barcode = Barcode;
    }
    
    public String getItemName() {
	return itemName;
    }
    
    public void setItemName(String itemName) {
	this.itemName = itemName;
    }
    
    public int getQuantity() {
	return Quantity;
    }
    
    public void incrementQuantity() {
	this.Quantity++;
    }
    
    public void setQuantity(int quantity) {
	Quantity = quantity;
    }
    
    public double getPrice() {
	return Price;
    }
    
    public void setPrice(double price) {
	Price = price;
    }
    
    public String getCategory() {
	return Category;
    }
    
    public void setCategory(String category) {
	Category = category;
    }
    
    @Override
    public boolean equals(Object o) {
	boolean success = false;
	
	try {
	    Product other = (Product) o;
	    if (other.Barcode.equals(this.Barcode)) {
		success = true;
	    }
	}
	catch (Throwable t) {
	}
	
	return success;
    }
    
    @Override
    public String toString() {
	return String.valueOf("Item name: " + this.getItemName() + "\r\nCategory: " + this.getCategory() + "\r\nPrice: " + this.getPrice() + "\r\nQuantity: " + this.getQuantity());
    }
}
